*******************************************************************************
* Turnout, all states
*******************************************************************************

use dataset_voters, clear
keep if !mi(turnout)
keep if inlist(year, 2000, 2012)
gen post = year == 2012
gen anyfrackingXpost = anyfracking*post
gen in_shaleXpost = in_shale_pl*post

eststo clear
eststo: reg turnout anyfrackingXpost post, a(zipcode) cl(zipcode) // ols
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

eststo: reg turnout in_shaleXpost post, a(zipcode) cl(zipcode) // rf
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

eststo: reg anyfrackingXpost in_shaleXpost post, a(zipcode) cl(zipcode) // fs
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)
test in_shaleXpost = 0
estadd scalar fstat = r(F)

eststo: tsls turnout post (anyfrackingXpost = in_shaleXpost), ///
	demean fe(zipcode) cluster(zipcode) // ss
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

*******************************************************************************
* Output table
*******************************************************************************

label variable anyfrackingXpost "Ever fracked X post"
label variable in_shaleXpost "In shale X post"

#delimit;

esttab
	using "_output/tableA3_a.tex"
	,
		replace
		booktabs
		keep(anyfrackingXpost in_shaleXpost) 
		cells(b(fmt(3) star) se(par))
		label
		gap
		collabels(none)	
		mtitles(
			"\shortstack{Turnout \\ (OLS)}" 
			"\shortstack{Turnout \\ (Reduced)}"
			"\shortstack{Ever fracked\\ X post (First)}"
			"\shortstack{Turnout \\ (Second)}"
		)
		width(\linewidth)
		stats(
			YFE
			ZFE
			Nzip
			N
			fstat
			,
				label(
					"Year fixed effects"
					"Zip code fixed effects" 
					"Clusters"
					"Observations"
					"F statistic"
				)
				fmt(0 %20.0fc)
		)
		;

#delimit cr

*******************************************************************************
* Turnout, high-fracking states
*******************************************************************************

keep if highf == 1
eststo clear
eststo: reg turnout anyfrackingXpost post, a(zipcode) cl(zipcode) // ols
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

eststo: reg turnout in_shaleXpost post, a(zipcode) cl(zipcode) // rf
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

eststo: reg anyfrackingXpost in_shaleXpost post, a(zipcode) cl(zipcode) // fs
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)
test in_shaleXpost = 0
estadd scalar fstat = r(F)

eststo: tsls turnout post (anyfrackingXpost = in_shaleXpost), ///
	demean fe(zipcode) cluster(zipcode) // ss
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)


#delimit;

esttab
	using "_output/tableA3_b.tex"
	,
		replace
		booktabs
		keep(anyfrackingXpost in_shaleXpost) 
		cells(b(fmt(3) star) se(par))
		label
		gap
		collabels(none)	
		mtitles(
			"\shortstack{Turnout \\ (OLS)}" 
			"\shortstack{Turnout \\ (Reduced)}"
			"\shortstack{Ever fracked\\ X post (First)}"
			"\shortstack{Turnout \\ (Second)}"
		)
		width(\linewidth)
		stats(
			YFE
			ZFE
			Nzip
			N
			fstat
			,
				label(
					"Year fixed effects"
					"Zip code fixed effects" 
					"Clusters"
					"Observations"
					"F statistic"
				)
				fmt(0 %20.0fc)
		)
		;

#delimit cr

*******************************************************************************
* End
*******************************************************************************
